Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit of Ptr type #406

Merged
merged 2 commits into from
Oct 23, 2023
Merged

Initial commit of Ptr type #406

merged 2 commits into from
Oct 23, 2023

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Sep 20, 2023

Ptr is like NonNull, but has many restrictions which make it so that using a Ptr in unsafe code requires much simpler soundness proofs. Notably, it supports a try_cast_into<U> method where U: ?Sized + KnownLayout, which is a building block of TryFromBytes.

src/lib.rs Outdated Show resolved Hide resolved
@joshlf joshlf force-pushed the try-cast-from branch 8 times, most recently from e7060e9 to d1e5b30 Compare September 26, 2023 18:56
@joshlf joshlf changed the title [WIP] KnownLayout::try_cast_from Initial commit of Ptr type Sep 26, 2023
@joshlf joshlf force-pushed the try-cast-from branch 2 times, most recently from dd004e4 to f082458 Compare September 26, 2023 19:19
@joshlf joshlf requested a review from jswrenn September 26, 2023 19:20
src/util.rs Outdated Show resolved Hide resolved
src/util.rs Outdated Show resolved Hide resolved
src/util.rs Outdated Show resolved Hide resolved
src/macros.rs Show resolved Hide resolved
src/util.rs Outdated Show resolved Hide resolved
src/util.rs Outdated Show resolved Hide resolved
src/util.rs Outdated Show resolved Hide resolved
@joshlf joshlf force-pushed the try-cast-from branch 4 times, most recently from 090a08f to 97d1484 Compare October 12, 2023 21:41
@joshlf joshlf mentioned this pull request Oct 16, 2023
@joshlf joshlf force-pushed the try-cast-from branch 2 times, most recently from 862dfc5 to 2528a71 Compare October 16, 2023 19:15
`Ptr` is like `NonNull`, but has many restrictions which make it so that
using a `Ptr` in unsafe code requires much simpler soundness proofs. In
particular, `try_cast_into` attempts to cast a `Ptr<[u8]>` into a
`Ptr<U>` where `U: ?Sized + KnownLayout`, and will be built upon in
future commits as a building block of `TryFromBytes`.

Because `try_cast_into` performs a runtime check to validate alignment,
this requires disabling Miri's "symbolic alignment check" feature. While
it would be possible to run both with and without that feature in order
to still test other code using symbolic alignment checking, I don't
think that the benefit is worth a) the complexity of passing the
information necessary for certain tests to not run under symbolic
alignment checking and, b) the extra CI time to run Miri tests twice.

Makes progress on #29
@joshlf joshlf added this pull request to the merge queue Oct 23, 2023
Merged via the queue into main with commit c925142 Oct 23, 2023
126 checks passed
@joshlf joshlf deleted the try-cast-from branch October 23, 2023 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants